#include <stdio.h>
#include <ctype.h>
/**
*conver sample:
* 123  1 2 3  +123 -123
* to int
*/

int myatoi(const char* str){
	char* tmp=str;
	int val=1;
	int ct=0;
	int minus=1;
	for(;*tmp!='\0';tmp++){
		if(*tmp=='-')
			minus=-1;
		else if(isdigit(*tmp)){
			ct++;
			if(ct==1){
				val=(*tmp)-'0';
			}else{
				val=val*10+(*tmp)-'0';
			}
		}
	}
	return val*minus;
}

int main(){
	char* a="123";
	char* b=" + 1 2 3";
	char* c=" - 12 3";
	char* sample[]={a,b,c};
	int i;
	for(i=0;i<3;i++){
		printf("%d\t",myatoi(sample[i]));
	}
	return 0;
}